package Client.Socket;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import Server.SocketManager;

public class GestorComunicacionesViejo implements Runnable {

	private SocketManager sm;
	private String clientSentence;
	private boolean parar;
	private JFrame jf;
	private String codigo;

	public GestorComunicacionesViejo(SocketManager socket, JFrame jframe)
	{
		sm = socket;
		clientSentence = "";
		parar = false;
		jf = jframe;
		codigo = "";
	}

	@Override
	public void run() {

		while (!parar)
		{
			try
			{
				clientSentence = sm.Leer();

				if (clientSentence.equals("TRAINS"))
				{
					JOptionPane.showMessageDialog(null, "I LIKE TRAINS", "fghjk", JOptionPane.ERROR_MESSAGE);
					}

				else if (codigo.equals("FUERA"))
				{
					parar = true;
					sm.CerrarSocket();
					sm.CerrarStreams();
				}

			} catch (Exception e)
			{
				jf.dispose();
				JOptionPane.showMessageDialog(null, "ERROR, SERVIDOR SATURADO O EL SERVIDOR SE HA CAIDO", "Error de conexion", JOptionPane.ERROR_MESSAGE);
				parar = true;
			}
		}
	}
}
